package com.example.qxfw.cshx.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.qxfw.common.entity.zy.CcshxImpDot;
import com.example.qxfw.cshx.mapper.CcshxImpDotMapper;
import com.example.qxfw.cshx.service.CshxZymbService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class ZymbServiceImpl implements CshxZymbService {
    @Autowired
    private CcshxImpDotMapper ccshxImpDotMapper;

    @Override
    public List<CcshxImpDot> getAllCcshxImpDot() {
        return ccshxImpDotMapper.selectList(null);
    }

    @Override
    public CcshxImpDot insertOneData(CcshxImpDot ccshxImpDot) {
        int insert = ccshxImpDotMapper.insert(ccshxImpDot);
        if (insert >0 ){
            return ccshxImpDot;
        }else {
            return null;
        }

    }

    @Override
    public CcshxImpDot updateById(CcshxImpDot ccshxImpDot) {
        int update = ccshxImpDotMapper.update(ccshxImpDot, new LambdaQueryWrapper<CcshxImpDot>()
                .eq(CcshxImpDot::getId, ccshxImpDot.getId()));
        if (update > 0) {
            return ccshxImpDot;
        }else {
            return null;
        }
    }

    @Override
    public int deleteById(int id) {
        return ccshxImpDotMapper.deleteById(id);
    }

    @Override
    public List<CcshxImpDot> getAllStationName() {
        return ccshxImpDotMapper.selectList(new LambdaQueryWrapper<CcshxImpDot>()
                .select(CcshxImpDot::getJoinstation)
                .groupBy(CcshxImpDot::getJoinstation));
    }
}
